home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / gpg.vbs < prev    next >
Text File  |  2003-08-13  |  5KB  |  170 lines

  1. ' Caption: GnuPG|
  2. ' Hint: Do some GnuPG actions|
  3. ' Icon: gpg.ico|
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is cvs.vbs, released Sun, 28 Jul 2002 14:06:54 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: gpg.vbs,v 1.1.2.2 2003/08/13 00:38:45 neum Exp $
  40. '
  41.  
  42. ' ScriptEngine=VBScript
  43.  
  44. option explicit
  45.  
  46. ' Remove the dot to include this file(s)
  47. '#include <consts>
  48. '#include <cmnfunc>
  49.  
  50. dim okbutton
  51. dim cancelbutton
  52.  
  53. sub Main(FileName)
  54.   if Documents.Count = 0 then
  55.     MsgBox "There is currently no file open.", vbCritical
  56.     exit sub
  57.   end if
  58.   if not CheckSave then
  59.     exit sub
  60.   end if
  61.   dim gsxexe
  62.   gsxexe = RegGetSettings("HKEY_LOCAL_MACHINE\SOFTWARE\Ascher\GnuPGShEx\", "")
  63.   if gsxexe = "" then
  64.     MsgBox "GPGSX not found." & vbCrLf & "This script requires GPGSX" & vbCrLf & "you can download it from http://web.utanet.at/ascherst/gpgsx/", vbCritical
  65.     exit sub
  66.   end if
  67.  
  68.   dim form
  69.   form = Create("TForm", Self)
  70.   with form
  71.     .Caption = "GnuPG"
  72.     .Position = "poOwnerFormCenter"
  73.     .BorderStyle = "bsDialog"
  74.     .Height = 300
  75.     .Width = 350
  76.   end with
  77.   dim cbo
  78.   cbo = Create("TComboBox", Self)
  79.   with cbo
  80.     .Parent = form
  81.     .Top = 20
  82.     .Left = 5
  83.     .Width = form.ClientWidth - 10
  84.     .Style = "csDropDownList"
  85.     .Items.Add "Encrypt"
  86.     .Items.Add "Decrypt"
  87.     .Items.Add "Sign"
  88.     .Items.Add "Verify"
  89.     .ItemIndex = 0
  90.   end with
  91.   with Create("TLabel", Self)
  92.     .Parent = form
  93.     .Caption = "&Do what:"
  94.     .Top = cbo.Top - 15
  95.     .Left = 5
  96.     .FocusControl = cbo
  97.   end with
  98.   
  99.   dim list
  100.  
  101.   list = Create("TCheckListBox", Self)
  102.   with list
  103.     .Parent = form
  104.     .Left = 5
  105.     .Top = 60
  106.     .Height = form.ClientHeight - 100
  107.     .Width = form.ClientWidth - 10
  108.     dim i, j
  109.     for i = 0 to Documents.Count - 1
  110.       if Documents(i).FileName <> "" then
  111.         j = .Items.Add(Documents(i).FileName)
  112.         .Checked(j) = true
  113.       end if
  114.     next
  115.   end with
  116.   
  117.   with Create("TLabel", Self)
  118.     .Parent = form
  119.     .Caption = "&Select files:"
  120.     .Top = list.Top - 15
  121.     .Left = 5
  122.     .FocusControl = list
  123.   end with
  124.   okbutton = Create("TButton", Self)
  125.   with okbutton
  126.     .Parent = form
  127.     .Caption = "OK"
  128.     .Default = true
  129.     .Left = form.ClientWidth - (.Width + 5) * 2
  130.     .Top = form.ClientHeight - .Height - 5
  131.     .ModalResult = mrOK
  132.   end with
  133.   cancelbutton = Create("TButton", Self)
  134.   with cancelbutton
  135.     .Parent = form
  136.     .Caption = "Cancel"
  137.     .Cancel = true
  138.     .Left = form.ClientWidth - .Width - 5
  139.     .Top = form.ClientHeight - .Height - 5
  140.     .ModalResult = mrCancel
  141.   end with
  142.  
  143.   if form.ShowModal = mrOK then
  144.   
  145.     dim files
  146.  
  147.     for j = 0 to list.Items.Count - 1
  148.       if list.Checked(j) then
  149.         files = files & " " & AddQuotesUnless(list.Items(j))
  150.       end if
  151.     next
  152.     if files <> "" then
  153.       files = Trim(files)
  154.       dim args
  155.       select case cbo.ItemIndex
  156.       case 0
  157.         args = " -encrypt -files " & files
  158.       case 1
  159.         args = " -decrypt -files " & files
  160.       case 2
  161.         args = " -sign -files " & files
  162.       case 3
  163.         args = " -verify -files " & files
  164.       end select
  165.     end if
  166.     Execute AddQuotesUnless(gsxexe) & args, 1, false
  167.   end if
  168.   form.Free
  169. end sub
  170.